﻿using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace netcore_service.Model
{

    public class ApiResult<T>
    {
        public bool Success { get; set; }
        public string Message { get; set; }
        public T Data { get; set; }
        public int total { get; set; }

    }
    public static class APIResult
    {
        public static ApiResult<T> GetSuccess<T>(T Data)
        {
            return new ApiResult<T>()
            {
                Success = true,
                Message = "成功",
                Data = Data
            };
        }
        public static ApiResult<T> GetSuccess<T>(T Data, int total)
        {
            return new ApiResult<T>()
            {
                Success = true,
                Message = "成功",
                Data = Data,
                total = total
            };
        }
        public static ApiResult<T> GetError<T>(T Data)
        {
            return new ApiResult<T>()
            {
                Success = false,
                Message = "失败",
                Data = Data
            };
        }

        public static ApiResult<T> GetError<T>(string Message)
        {
            return new ApiResult<T>()
            {
                Success = false,
                Message = Message
            };
        }
    }
}
